/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.anniversary.repository;

import me.zhengjie.modules.anniversary.domain.Photos;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
* @website https://el-admin.vip
* @author Jiayin Wei
* @date 2020-07-27
**/
public interface PhotosRepository extends JpaRepository<Photos, Long>, JpaSpecificationExecutor<Photos> {
    /**
     * 首页中的轮播图
     * @param pageable
     * @return
     */
    @Query(value = "select * from gzmu_ann_photos WHERE verify_status=1 AND is_enable=1 AND path is NOT NULL AND type=0 ORDER BY sort DESC", nativeQuery = true)
    List<Map<String,Object>> findByRotation(Pageable pageable);

    /**
     * 分页查询民大剪影中的信息
     * @param pageable
     * @return
     */
    @Query(value = "select * from gzmu_ann_photos WHERE verify_status=1 AND is_enable=1 AND path is NOT NULL AND type=0 ORDER BY create_time DESC", nativeQuery = true)
    List<Map<String,Object>> findByPhotos(Pageable pageable);
}
